﻿// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");

var g1 = Guid.NewGuid();

var b = g1.ToByteArray();



long msb = 0;
long lsb = 0;
for (int i = 0; i < 8; i++)
{
    msb = (msb << 8) | (b[i] & 0xff);
    lsb = (lsb << 8) | (b[i + 8] & 0xff);
}


Span<byte> b2 = new byte[16];
for (int i = 0; i < 8; i++)
{
    b2[i] = (byte)(msb >> (8 * (7 - i)) & 0xff);
    b2[i + 8] = (byte)(lsb >> (8 * (7 - i)) & 0xff);
}

var g2 = new Guid(b2);

Console.WriteLine(g1 == g2);

Console.ReadKey();
